<template>
	<view>
		<view class="kuang" style="margin-top: 20rpx;" v-if="zhuangtai != ''">
			<view class="title">审核结果</view>
			<view style="color: #38D180;font-size: 28rpx;" v-if="jinyong != 2">审核状态：{{ zhuangtai }}</view>
			<view v-if="audit == 2&&jinyong != 2" style="color: #ff0000;font-size: 28rpx;">驳回原因：{{ yuanyin }}</view>
			<view v-if="jinyong == 2" style="color: #ff0000;font-size: 28rpx;">很抱歉，您的账号已经被平台禁用</view>
		</view>
		<view class="input-container" style="margin-top: 20rpx;">
			<view class="title">商户资料</view>
			<view class="uni-row input-item">
				<view class="input-name">店铺名称</view>
				<view class="input">
					<input type="text" :disabled="disabled" v-model="name" placeholder="请填写营业执照上的真实名称" placeholder-style="font-size:28rpx;color:#999999" />
				</view>
			</view>
			<view class="uni-row input-item input-relact" @tap="show_type()">
				<view class="input-name">类型</view>
				<view class="input">
					<input
						type="text"
						:disabled="disabled"
						v-model="shangpu_type.cate_name"
						placeholder="请填写商户类型"
						placeholder-style="font-size:28rpx;color:#999999"
						disabled="true"
					/>
				</view>
				<image src="../../static/images/heijiao.png" class="xuanze-sj"></image>
			</view>
			<view class="uni-row input-item">
				<view class="input-name">负责人</view>
				<view class="input"><input type="text" :disabled="disabled" v-model="linkman" placeholder="填写法人姓名" placeholder-style="font-size:28rpx;color:#999999" /></view>
			</view>
			<view class="uni-row input-item">
				<view class="input-name">负责人电话</view>
				<view class="input"><input type="text" :disabled="disabled" v-model="phone" placeholder="填写手机号" placeholder-style="font-size:28rpx;color:#999999" /></view>
			</view>
			<view class="uni-row input-item input-relact" @tap="address_show_action()">
				<view class="input-name">所在地区</view>
				<view class="input"><input type="text" v-model="diqu" placeholder="请选择店铺所在地区" placeholder-style="font-size:28rpx;color:#999999" disabled="true" /></view>
				<image src="../../static/images/heijiao.png" class="xuanze-sj"></image>
			</view>
			<view class="uni-row input-item">
				<view class="input-name">地址</view>
				<view class="input">
					<input type="text" :disabled="disabled" v-model="xixaddress" placeholder="填写店铺地址" placeholder-style="font-size:28rpx;color:#999999" />
				</view>
			</view>
		</view>
		<view class="input-container">
			<view class="title">上传凭证</view>
			<view class="uni-row">
				<view class="up-item" v-if="imgs1.length != 0">
					<view class="up-img-container">
						<image src="../../static/images/del-icon.png" class="del-icon" @tap="delimg(1)"></image>
						<image :src="imgs1[0].img" class="up-img" @tap="yulan(imgs1[0].img)"></image>
					</view>
					<view class="up-name">营业执照</view>
				</view>
				<view class="up-item" v-if="imgs1.length == 0">
					<view class="up-img-container"><image src="../../static/images/upload.png" class="up-img" @tap="upload(1)"></image></view>
					<view class="up-name">营业执照</view>
				</view>

				
				<view class="up-item" v-if="imgs4.length != 0">
					<view class="up-img-container">
						<image src="../../static/images/del-icon.png" class="del-icon" @tap="delimg(4)"></image>
						<image :src="imgs4[0].img" @tap="yulan(imgs4[0].img)" class="up-img"></image>
					</view>
					<view class="up-name">店铺门头</view>
				</view>
				<view class="up-item" v-if="imgs4.length == 0">
					<view class="up-img-container"><image src="../../static/images/upload.png" class="up-img" @tap="upload(4)"></image></view>
					<view class="up-name">店铺门头</view>
				</view>
				<view class="up-item" v-if="imgs6.length != 0">
					<view class="up-img-container">
						<image src="../../static/images/del-icon.png" class="del-icon" @tap="delimg(6)"></image>
						<image :src="imgs6[0].img" class="up-img" @tap="yulan(imgs6[0].img)"></image>
					</view>
					<view class="up-name">食品经营许可证</view>
				</view>
				<view class="up-item" v-if="imgs6.length == 0">
					<view class="up-img-container"><image src="../../static/images/upload.png" class="up-img" @tap="upload(6)"></image></view>
					<view class="up-name">食品经营许可证</view>
				</view>
			</view>
			
		</view>
		<view class="input-container">
			<view class="title">上传身份证（选填）</view>
			<view class="uni-row">
				<view class="up-item" v-if="imgs2.length != 0">
					<view class="up-img-container">
						<image src="../../static/images/del-icon.png" class="del-icon" @tap="delimg(2)"></image>
						<image :src="imgs2[0].img" class="up-img" @tap="yulan(imgs2[0].img)"></image>
					</view>
					<view class="up-name">申请人身份证(正)</view>
				</view>
				<view class="up-item" v-if="imgs2.length == 0" >
					<view class="up-img-container"><image src="../../static/images/upload.png" class="up-img" @tap="upload(2)"></image></view>
					<view class="up-name">申请人身份证(正)</view>
				</view>
				
				<view class="up-item" v-if="imgs3.length != 0">
					<view class="up-img-container">
						<image src="../../static/images/del-icon.png" class="del-icon" @tap="delimg(3)"></image>
						<image :src="imgs3[0].img" class="up-img" @tap="yulan(imgs3[0].img)"></image>
					</view>
					<view class="up-name">申请人身份证(反)</view>
				</view>
				<view class="up-item" v-if="imgs3.length == 0">
					<view class="up-img-container"><image src="../../static/images/upload.png" class="up-img" @tap="upload(3)"></image></view>
					<view class="up-name">申请人身份证(反)</view>
				</view>
			</view>
			
		</view>
		<button class="big-btn" @tap="tijiaoshenqing()">立即申请</button>
		<!-- 选择商铺类型 -->
		<view class="tanchukuang" v-show="leixing_show">
			<view class="mark"></view>
			<view class="phone-kuang">
				<view class="bang-title">选择商铺类型</view>
				<view>
					<scroll-view class="gundong" scroll-y="true">
						<view class="">
							<view class="xuanze-item" v-for="(item, index) in typelist" :key="index" :data-id="item.id" @tap="xuanzetype">
								<image :src="item.img"></image>
								{{ item.cate_name }}
							</view>
						</view>
					</scroll-view>
				</view>
				<button class="bang-btn" @tap="quexiyan()">确定</button>
			</view>
			<image class="closebangding" src="../../static/images/fan-close.png" @tap="quexiyan()"></image>
		</view>
		<!-- 地址弹出框 -->
		<view v-show="address_show">
			<view class="mark"></view>
			<view class="address-container">
				<view class="address-title border-bottom">
					<text v-if="choose_address.province">{{ choose_address.province }}——</text>
					<text v-if="choose_address.city">{{ choose_address.city }}——</text>
					<text v-if="choose_address.town">{{ choose_address.town }}</text>
					<image src="../../static/images/pay-close.png" style="float: right;width: 32rpx;height: 32rpx;" @tap="close_address()"></image>
				</view>
				<view class="uni-row">
					<view class="address-item" style="border-right: 1px solid #F2F2F2;">
						<scroll-view scroll-y="true" class="scroll-view">
							<view>
								<view class="city-name " v-for="(item, index) in provinces" :key="index" @tap="xuanzedizhi" :data-id="item.id" :data-index="index">
									<image :src="item.img"></image>
									{{ item.name }}
								</view>
							</view>
						</scroll-view>
					</view>
					<view class="address-item" style="padding-left: 32rpx;box-sizing: border-box;border-right: 1px solid #F2F2F2;">
						<scroll-view scroll-y="true" class="scroll-view">
							<view>
								<view class="city-name " v-for="(item, index) in citys" @tap="xuanzecity" :data-id="item.id" :key="index" :data-name="item.name">
									<image :src="item.img"></image>
									{{ item.name }}
								</view>
							</view>
						</scroll-view>
					</view>
					<view class="address-item" style="padding-left: 32rpx;box-sizing: border-box;">
						<scroll-view scroll-y="true" class="scroll-view">
							<view>
								<view class="city-name " v-for="(item, index) in townlist" @tap="xuanzetown" :key="index" :data-id="item.id" :data-name="item.name">
									<image :src="item.img"></image>
									{{ item.name }}
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getlogin } from '@/static/js/login.js';
import httpPath from '@/static/js/path.js';
export default {
	data() {
		return {
			yuanyin: '',
			typelist: [],
			leixing_show: false,
			address_show: false,
			amapPlugin: null,
			provinces: [],
			citys: [],
			choosedprovinces: '',
			key: '127a8a73b4bb644c0893d7a4d14b246a',
			region: {},
			choosedcity: '',
			choose_address: {},
			townlist: [],
			provincesindex: 0,
			cityindex: 0,
			diqu: '',
			name: '',
			linkman: '',
			phone: '',
			wxinfo_id: '', //用户id
			addressinfo: '',
			imgs1: [], //图片数组
			imgs2: [],
			imgs3: [],
			imgs4: [],
			// imgs5: [],
			imgs6: [],
			userinfo: {},
			shangpu_type: {}, //商铺类型
			linkman: '', //法人
			phone: '', //法人电话
			xixaddress: '', //详细地址
			disabled: false,
			zhuangtai: '',
			audit: '',//审核状态0，待审，1审核成功，2审核失败
            jinyong:""//禁用
		};
	},
	onShow() {},
	onLoad() {
		this.userinfo = getlogin();
		this.wxinfo_id = this.userinfo.wxinfo_id;
		this.getinfo();
		this.gettype();
		
	},
	methods: {
		/**
		 * @param {Object} img预览图片
		 */
		yulan(img) {
			uni.previewImage({
				urls: [img],
				longPressActions: {
					// itemList: ['发送给朋友', '保存图片', '收藏'],
					success: function(data) {
						console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
					},
					fail: function(err) {
						console.log(err.errMsg);
					}
				}
			});
		},
		/**
		 * 获取申请的数据
		 */
		getinfo() {
			uni.request({
				url: httpPath.filePath + '/index/merchant/index',
				method: 'POST',
				header: { 'content-type': 'application/x-www-form-urlencoded' },
				data: { wxinfo_id: this.wxinfo_id },
				success: res => {
					if (res.data.code == 200) {
						console.log(res.data.data);

						if (res.data.data.length != 0) {
							let data = res.data.data;
							this.name = data.name;
							this.shangpu_type = { id: data.type, cate_name: data.type_name.cate_name };
							this.linkman = data.linkman;
							this.phone = data.phone;
							this.xixaddress = data.address;
							this.opening_bank = data.opening_bank;
							this.bank_card = data.bank_card;
							this.imgs1 = [{ id: data.business_license.id, img: httpPath.filePath + data.business_license.filepath }];
							if(data.identity_card_z.filepath!=""){
                                this.imgs2 = [{ id: data.identity_card_z.id, img: httpPath.filePath + data.identity_card_z.filepath }];
                            }
                            if(data.identity_card_z.filepath!=""){
                                this.imgs3 = [{ id: data.identity_card_f.id, img: httpPath.filePath + data.identity_card_f.filepath }];
                            }
							
							this.imgs4 = [{ id: data.logo.id, img: httpPath.filePath + data.logo.filepath }];
							// this.imgs5 = [{ id: data.thumb.id, img: httpPath.filePath + data.thumb.filepath }];
							this.imgs6 = [{ id: data.spu_img.id, img: httpPath.filePath + data.spu_img.filepath }];
							this.choose_address.provinceid = data.province;
							this.choose_address.province = data.province_name.name;
							this.choose_address.cityid = data.city;
							this.choose_address.city = data.city_name.name;
							this.choose_address.townid = data.county;
							this.choose_address.town = data.county_name.name;
							console.log(this.choose_address);
							this.diqu = this.choose_address.province + this.choose_address.city + this.choose_address.town;
							this.audit = data.audit;
							this.jinyong = data.status;
							if (data.audit == 2) {
								this.zhuangtai = '审核失败';
								this.disabled = false;
								this.userinfo.role = 'p';
							} else if (data.audit == 1) {
								this.zhuangtai = '审核成功';
								this.disabled = true;
								this.userinfo.role = 's';
							} else if (data.audit == 0) {
								this.zhuangtai = '等待审核';
								this.disabled = true;
								this.userinfo.role = 'p';
							}
							uni.setStorage({
								key: 'user',
								data: this.userinfo,
								success: function() {}
							});
							this.yuanyin = data.cause;
						}
					}
				}
			});
		},
		/**
		 * @param {Object} 选择商户类型
		 */
		xuanzetype(e) {
			if (this.audit === 0&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '请耐心等待审核'
				});
				return false;
			} else if (this.audit == 1&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '已经审核通过，若要修改请联系平台'
				});
				return false;
			}else if(this.jinyong===2){
                uni.showModal({
                	showCancel: false,
               	content: '您的账号平台已禁用，请联系平台'
                });
                return false;
            }
			let id = e.currentTarget.dataset.id;
			for (let i = 0; i < this.typelist.length; i++) {
				if (this.typelist[i].id == id) {
					this.shangpu_type = this.typelist[i];
					this.typelist[i].checked = 1;
					this.typelist[i].img = '../../static/images/xuanzhong.png';
				} else {
					this.typelist[i].checked = 0;
					this.typelist[i].img = '../../static/images/weixuanzhong.png';
				}
			}
			console.log(this.shangpu_type);
		},
		/**
		 * 获取店铺类型
		 */
		gettype() {
			uni.request({
				url: httpPath.filePath + '/index/merchant/type',
				method: 'POST',
				header: { 'content-type': 'application/x-www-form-urlencoded' },
				data: {},
				success: res => {
					if (res.data.code == 200) {
						if (res.data.data.length != 0) {
							this.typelist = res.data.data;
							for (let i = 0; i < this.typelist.length; i++) {
								this.typelist[i].checked = 0;
								this.typelist[i].img = '../../static/images/weixuanzhong.png';
							}
						}
					}
				}
			});
		},
		quexiyan() {
			this.leixing_show = false;
		},
		/**
		 * 点击类型时显示类型选择框
		 */
		show_type() {
			if (this.audit === 0&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '请耐心等待审核'
				});
				return false;
			} else if (this.audit == 1&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '已经审核通过，若要修改请联系平台'
				});
				return false;
			}else if(this.jinyong===2){
			    uni.showModal({
			    	showCancel: false,
			   	content: '您的账号平台已禁用，请联系平台'
			    });
			    return false;
			}
			this.leixing_show = true;
		},
		/**
		 * 提交申请
		 */
		tijiaoshenqing() {
			if (this.audit === 0&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '请耐心等待审核'
				});
				return false;
			} else if (this.audit == 1&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '已经审核通过，若要修改请联系平台'
				});
				return false;
			}else if(this.jinyong===2){
			    uni.showModal({
			    	showCancel: false,
			   	content: '您的账号平台已禁用，请联系平台'
			    });
			    return false;
			}
			let $phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
			if (!this.name) {
				uni.showModal({
					showCancel: false,
					content: '请填写店铺名称'
				});
				return false;
			}
			if (!this.shangpu_type) {
				uni.showModal({
					showCancel: false,
					content: '请选择商铺类型'
				});
				return false;
			}
			if (!this.linkman) {
				uni.showModal({
					showCancel: false,
					content: '请填写法人姓名'
				});
				return false;
			}
			if (!this.phone) {
				uni.showModal({
					showCancel: false,
					content: '请填写手机号'
				});
				return false;
			} else if (!$phone.test(this.phone)) {
				uni.showModal({
					showCancel: false,
					content: '请填写正确的手机号'
				});
			}
			if (
				this.choose_address.provinceid == '' ||
				this.choose_address.provinceid == null ||
				this.choose_address.cityid == '' ||
				this.choose_address.cityid == null ||
				this.choose_address.townid == '' ||
				this.choose_address == null
			) {
				uni.showModal({
					showCancel: false,
					content: '请选择地区'
				});
				return false;
			}
			if(!this.xixaddress){
				uni.showModal({
					showCancel: false,
					content: '请填写详细地址'
				});
				return false;
			}
			// if (!this.opening_bank) {
			// 	uni.showModal({
			// 		showCancel: false,
			// 		content: '请填写开户行'
			// 	});
			// 	return false;
			// }
			// if (!this.bank_card) {
			// 	uni.showModal({
			// 		showCancel: false,
			// 		content: '请填写开户行账号'
			// 	});
			// 	return false;
			// }
			if (this.imgs1.length == 0) {
				uni.showModal({
					showCancel: false,
					content: '请上传营业执照'
				});
				return false;
			}
            let identity_card_z=""
            let identity_card_f=""
			if (this.imgs2.length != 0) {
                identity_card_z=this.imgs2[0].id;
				// uni.showModal({
				// 	showCancel: false,
				// 	content: '请上传法人身份证正面照片'
				// });
				// return false;
			}
			if (this.imgs3.length != 0) {
                identity_card_f=this.imgs3[0].id;
				// uni.showModal({
				// 	showCancel: false,
				// 	content: '请上传法人身份证反面照片'
				// });
				// return false;
			}
			if (this.imgs4.length == 0) {
				uni.showModal({
					showCancel: false,
					content: '请上传店铺门头'
				});
				return false;
			}
			// if (this.imgs5.length == 0) {
			// 	uni.showModal({
			// 		showCancel: false,
			// 		content: '请上传店内照片'
			// 	});
			// 	return false;
			// }
			if (this.imgs6.length == 0) {
				uni.showModal({
					showCancel: false,
					content: '请上传食品经营许可证'
				});
				return false;
			}
			let data = {
				name: this.name,
				type: this.shangpu_type.id,
				linkman: this.linkman,
				phone: this.phone,
				province: this.choose_address.provinceid,
				city: this.choose_address.cityid,
				county: this.choose_address.townid,
				address: this.xixaddress,
				// opening_bank: this.opening_bank,
				// bank_card: this.bank_card,
				business_license: this.imgs1[0].id,
				identity_card_z: identity_card_z,
				identity_card_f: identity_card_f,
				logo: this.imgs4[0].id,
				// thumb: this.imgs5[0].id,
				spu_img: this.imgs6[0].id,
				wxinfo_id: this.userinfo.wxinfo_id
			};

			uni.request({
				url: httpPath.filePath + '/index/merchant/add',
				method: 'POST',
				header: { 'content-type': 'application/x-www-form-urlencoded' },
				data: data,
				success: res => {
					if (res.data.code == 200) {
						this.getinfo();
						uni.showModal({
							showCancel: false,
							content: res.data.msg
						});
						this.disabled = false;
					} else {
						uni.showModal({
							showCancel: false,
							content: res.data.msg
						});
					}
				}
			});
		},
		/**
		 * @param {Object} type 删除图片type为删除类型
		 */
		delimg(type) {
			if (this.audit === 0&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '请耐心等待审核'
				});
				return false;
			} else if (this.audit == 1&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '已经审核通过，若要修改请联系平台'
				});
				return false;
			}else if(this.jinyong===2){
			    uni.showModal({
			    	showCancel: false,
			   	content: '您的账号平台已禁用，请联系平台'
			    });
			    return false;
			}
			let $this = this;
			switch (type) {
				case 1:
					{
						$this.imgs1 = [];
					}
					break;
				case 2:
					{
						$this.imgs2 = [];
					}
					break;
				case 3:
					{
						$this.imgs3 = [];
					}
					break;
				case 4:
					{
						$this.imgs4 = [];
					}
					break;
				case 6:
					{
						$this.imgs6 = [];
					}
					break;
			}
		},
		/**
		 * @param {Object} type上传图片
		 */
		upload(type) {
			console.log(type)
			let $this = this;
			wx.chooseImage({
				count: 1, //默认9
				sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				sourceType: ['album', 'camera'],
				success: function(res) {
					wx.uploadFile({
						url: httpPath.filePath + '/index/common/upload_m', //仅为示例，非真实的接口地址
						filePath: res.tempFilePaths[0],
						name: 'img',
						formData: {
							user: 'test'
						},
						success(res) {
							console.log(res);
							let data = JSON.parse(res.data);
							if (data.code == 1) {
								switch (type) {
									case 1:
										{
											$this.imgs1 = [];
											$this.imgs1.push({ id: data.id, img: httpPath.filePath + data.msg });
										}
										break;
									case 2:
										{
											$this.imgs2 = [];
											$this.imgs2.push({ id: data.id, img: httpPath.filePath + data.msg });
										}
										break;
									case 3:
										{
											$this.imgs3 = [];
											$this.imgs3.push({ id: data.id, img: httpPath.filePath + data.msg });
										}
										break;
									case 4:
										{
											$this.imgs4 = [];
											$this.imgs4.push({ id: data.id, img: httpPath.filePath + data.msg });
										}
										break;
									
									case 6:
										{
											$this.imgs6 = [];
											$this.imgs6.push({ id: data.id, img: httpPath.filePath + data.msg });
										}
										break;
								}
							} else {
								uni.showModal({
									showCancel: false,
									content: data.msg
								});
							}
						}
					});
				}
			});
		},
		/**
		 * 获得地区
		 */
		getaddress() {
			uni.request({
				url: httpPath.filePath + '/index/regoin/index',
				method: 'POST',
				header: { 'content-type': 'application/x-www-form-urlencoded' },
				data: {},
				success: res => {
					uni.setStorage({
						key: 'address',
						data: res.data.data.region,
						success: function() {}
					});
				}
			});
		},
		close_address() {
			this.address_show = false;
		},
		address_show_action() {
			if (this.audit === 0&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '请耐心等待审核'
				});
				return false;
			} else if (this.audit == 1&&this.jinyong===1) {
				uni.showModal({
					showCancel: false,
					content: '已经审核通过，若要修改请联系平台'
				});
				return false;
			}else if(this.jinyong===2){
			    uni.showModal({
			    	showCancel: false,
			   	content: '您的账号平台已禁用，请联系平台'
			    });
			    return false;
			}
			let $this = this;
			$this.provinces = [];
			const address = uni.getStorageSync('address');
			if (!address) {
				this.getaddress();
			}
			uni.getStorage({
				key: 'address',
				success: function(res) {
					$this.region = res.data;
					for (let i = 0; i < res.data.length; i++) {
						$this.provinces.push({ name: res.data[i].name, id: res.data[i].id, checked: 0, img: '../../static/images/weixuanzhong.png' });
					}
				}
			});
			this.address_show = true;
		},
		/**
		 *选择省
		 */
		xuanzedizhi(e) {
			let $this = this;
			this.citys = [];
			let id = e.currentTarget.dataset.id;
			let index = e.currentTarget.dataset.index;
			for (let i = 0; i < $this.region.length; i++) {
				if ($this.region[i].id == id) {
					$this.provincesindex = i;
					$this.provinces[i].img = '../../static/images/xuanzhong.png';
					$this.provinces[i].check = 1;
					// $this.choosedprovinces = $this.provinces[i].name;
					$this.choose_address.province = $this.provinces[i].name;
					$this.choose_address.provinceid = $this.provinces[i].id;
					for (let j = 0; j < $this.region[i].city.length; j++) {
						$this.citys.push({ name: $this.region[i].city[j].name, id: $this.region[i].city[j].id, checked: 0, img: '../../static/images/weixuanzhong.png' });
					}
				} else {
					$this.provinces[i].img = '../../static/images/weixuanzhong.png';
					$this.provinces[i].check = 0;
				}
			}
		},
		/**
		 * 选择市
		 */ xuanzecity(e) {
			let $this = this;
			this.choose_address.cityid = e.currentTarget.dataset.id;
			this.choose_address.city = e.currentTarget.dataset.name;
			let citylist = this.region[this.provincesindex].city;

			for (let j = 0; j < citylist.length; j++) {
				if (citylist[j].id == this.choose_address.cityid) {
					this.cityindex = j;
					$this.citys[j].img = '../../static/images/xuanzhong.png';
					$this.citys[j].check = 1;
					let townlist = citylist[j].county;
					console.log(townlist);
					this.townlist = [];
					for (let a = 0; a < townlist.length; a++) {
						this.townlist.push({ name: townlist[a].name, id: townlist[a].id, checked: 0, img: '../../static/images/weixuanzhong.png' });
					}
				} else {
					$this.citys[j].img = '../../static/images/weixuanzhong.png';
					$this.citys[j].check = 0;
				}
			}
		},
		/**
		 * 选择区县
		 */ xuanzetown(e) {
			let $this = this;
			this.choose_address.townid = e.currentTarget.dataset.id;
			this.choose_address.town = e.currentTarget.dataset.name;
			let townslist = this.region[this.provincesindex].city[this.cityindex];

			for (let j = 0; j < townslist.length; j++) {
				if (townslist[j].id == this.choose_address.townid) {
					this.cityindex = j;
					$this.townlist[j].img = '../../static/images/xuanzhong.png';
					$this.townlist[j].check = 1;
				} else {
					$this.townlist[j].img = '../../static/images/weixuanzhong.png';
					$this.townlist[j].check = 0;
				}
			}
			this.diqu = this.choose_address.province + this.choose_address.city + this.choose_address.town;
			this.address_show = false;
		}
	}
};
</script>

<style>
page {
	background: #f9f9f9;
}
.address-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #7adba8;
	text-align: center;
	padding-bottom: 20rpx;
}
.scroll-view {
	height: 100%;
}
.city-name {
	height: 90rpx;
	line-height: 90rpx;
	font-size: 28rpx;
	color: #666;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.city-name image {
	width: 36rpx;
	height: 36rpx;
	vertical-align: middle;
	margin-right: 20rpx;
}
.address-container {
	z-index: 100000;
	position: fixed;
	bottom: 0rpx;
	left: 0px;
	background: #fff;
	height: 662rpx;
	padding: 32rpx;
	box-sizing: border-box;
	width: 100%;
}
.address-item {
	width: 33.3%;
	height: 550rpx;
	box-sizing: border-box;
}
.gundong {
	height: 300rpx;
}
.tanchukuang {
	z-index: 10000;
}
.phone-kuang {
	position: fixed;
	top: 340rpx;
	left: 32rpx;
	width: 686rpx;
	background: #ffffff;
	border-radius: 5px;
	padding: 80rpx 45rpx;
	box-sizing: border-box;
}
.bang-title {
	font-size: 32rpx;
	text-align: center;
	font-weight: bold;
}
.bang-item {
	height: 60rpx;
	line-height: 60rpx;
	margin-top: 40rpx;
}
.bang-item image {
	width: 45rpx;
	height: 45rpx;
	vertical-align: middle;
	margin-right: 64rpx;
}
.bang-item input {
	border: none;
	font-size: 28rpx;
}
.code-btn {
	width: 129rpx;
	height: 64rpx;
	color: rgba(56, 209, 128, 1);
	border: 1px solid rgba(56, 209, 128, 1);
	border-radius: 12rpx;
	position: absolute;
	top: -15rpx;
	font-size: 28rpx;
	right: 10rpx;
}
.bang-btn {
	margin-top: 80rpx;
	width: 404rpx;
	height: 90rpx;
	line-height: 90rpx;
	background: linear-gradient(135deg, rgba(80, 80, 80, 1), rgba(51, 51, 51, 1));
	border-radius: 45rpx;
	font-size: 28rpx;
	color: #ffffff;
}
.closebangding {
	width: 54rpx;
	height: 54rpx;
	position: fixed;
	bottom: 120rpx;
	left: calc(50% - 27rpx);
}
.xuanze-item {
	height: 80rpx;
	font-size: 28rpx;
	color: #666666;
	line-height: 80rpx;
	padding-left: 150rpx;
}
.xuanze-item image {
	width: 36rpx;
	height: 36rpx;
	vertical-align: middle;
	margin-right: 20rpx;
}
</style>
